<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="/static/layui/css/layui.css">
</head>
<body>

<form class="layui-form layui-form-pane" action="">
    <div class="layui-form-item">
        <label class="layui-form-label">权限名</label>
        <div class="layui-input-block">
            <input type="text" name="name" autocomplete="off" placeholder="权限名" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">权限路径</label>
        <div class="layui-input-block">
            <input type="text" name="path" autocomplete="off" placeholder="权限路径" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">角色</label>
        <div class="layui-input-block">
            <select name="role">
                <option value="1">超级管理员</option>
                <option value="2">普通管理员</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit="" lay-filter="submitForm">添加</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<script src="/static/jquery-2.1.4.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/layui/layui.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/mylayer.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/kindeditor/kindeditor.js" type="text/javascript" charset="utf-8"></script>
<script>

    layui.use(['form','upload'], function () {
        var form = layui.form;
        var upload = layui.upload;

        form.on('submit(submitForm)', function(data){
            console.log(data.field);
            $.post(
                '/auth?method=add',
                data.field,
                function (result) {
                    console.log(result);
                    if (result.code == 0) {
                        mylayer.okMsg(result.msg);
                        setInterval(function () {
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                            window.parent.location.reload();
                        }, 2000);
                    }
                },
                'json'
            );
            return false;
        });
    });
</script>
</body>
</html>
